#ifndef PURCHASEDIALOG_H
#define PURCHASEDIALOG_H

#include <QDialog>
#include "mainwindow.h"
#include "ui_purchasedialog.h"
#include <QCloseEvent>
#include <QDateTime>
#include <QDebug>
#include <QList>
#include <QSqlQuery>
#include "purchaseeditdialog.h"
#include <QMessageBox>
class MainWindow;
namespace Ui {

class PurchaseDialog;
}

//使用一个结构体来存从数据库的表中读出来的数据
struct Record_goods
{
    QString goods_id;
    QString goods_name;
    QString category;
    QString brand;
    QString size;
    QString color;
    QString number;
    QString unit;
    QString into_price;
    QString sale_price;
    QString sum;
    Record_goods(QSqlQuery *resg) {
        goods_id=resg->value("id").toString();
        goods_name=resg->value("goods_name").toString();
        category=resg->value("category").toString();
        brand=resg->value("brand").toString();
        size=resg->value("size").toString();
        color=resg->value("color").toString();
        number=resg->value("number").toString();
        unit=resg->value("unit").toString();
        into_price=resg->value("into_price").toString();
        sale_price=resg->value("sale_price").toString();
        sum=resg->value("sum").toString();
    }
};

class PurchaseDialog : public QDialog
{
    Q_OBJECT

public:
    explicit PurchaseDialog(QWidget *parent = 0, MainWindow *_MainWindow = 0);
    void update_purchaseinfo(QList<Record_goods> *_date = NULL);
    void init(QString filed="");
    ~PurchaseDialog();

private:
    MainWindow *pMainWindow;
    Ui::PurchaseDialog *ui;
    int pageTotal = -1;
    int pageNow =1;
    QList<Record_goods>datePrevious_goods;
    QList<Record_goods>dateNow_goods;
    QList<Record_goods>dateForword_goods;

signals:
     void purchaseClose(int x);

protected:
     void closeEvent(QCloseEvent *event);
private slots:
     void updata_time();
     void on_sales_pushButton_clicked();
     void on_vip_pushButton_clicked();
     void on_exit_pushButton_clicked();
     void on_comboBox_category_currentIndexChanged(const QString &arg1);
     void on_comboBox_brand_currentIndexChanged(const QString &arg1);
     void on_comboBox_name_currentIndexChanged(const QString &arg1);
     void on_pushButton_add_clicked();
};

#endif // PURCHASEDIALOG_H
